package com.medical.app.service.impl;

import com.medical.app.common.vo.FloorIndexVo;
import com.medical.app.common.vo.HealthyEssayVo;
import com.medical.app.common.vo.HospitalBuildingVo;
import com.medical.app.common.vo.HospitalVo;
import com.medical.app.entity.FloorIndex;
import com.medical.app.entity.HealthyEssay;
import com.medical.app.entity.Hospital;
import com.medical.app.entity.HospitalBuilding;
import com.medical.app.mapper.FloorIndexMapper;
import com.medical.app.mapper.HealthyEssayMapper;
import com.medical.app.mapper.HospitalBuildingMapper;
import com.medical.app.mapper.HospitalMapper;
import com.medical.app.service.HospitalServerService;
import com.qf.medical.utils.BeanConvertUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description: some desc
 * @author: LuAn
 * @date: 2024/4/30
 */
@Service
public class HospitalServerServiceImpl implements HospitalServerService {
    @Resource
    private HospitalBuildingMapper hospitalBuildingMapper;
    @Resource
    private FloorIndexMapper floorIndexMapper;
    @Resource
    private HospitalMapper hospitalMapper;
    @Resource
    private HealthyEssayMapper healthyEssayMapper;
    /**
     * 展示医院信息
     * @return
     */
    @Override
    public List<HospitalVo> selectHospitals() {
        List<Hospital> hospitals= hospitalMapper.selectHospitals();
        return BeanConvertUtils.convertListTo(hospitals,HospitalVo::new);
    }

    /**
     * 展示医院详情
     * @param hospitalId
     * @return
     */
    @Override
    public HospitalVo selectHospital(Long hospitalId) {
        Hospital hospital= hospitalMapper.selectHospital(hospitalId);
        return BeanConvertUtils.convertTo(hospital,HospitalVo::new);
    }

    /**
     * 展示楼栋信息
     * @param hospitalId
     * @return
     */
    @Override
    public List<HospitalBuildingVo> selectBuildings(Long hospitalId) {
        List<HospitalBuilding> hospitalBuildings = hospitalBuildingMapper.selectByHospitalId(hospitalId);
        return BeanConvertUtils.convertListTo(hospitalBuildings,HospitalBuildingVo::new);
    }

    /**
     * 展示楼层信息详情
     * @param hospitalBuildingId
     * @return
     */
    @Override
    public List<FloorIndexVo> selectFloorIndex(Long hospitalBuildingId) {
        List<FloorIndex> floorIndexList= floorIndexMapper.selectByHospitalBuildingId(hospitalBuildingId);
        return BeanConvertUtils.convertListTo(floorIndexList,FloorIndexVo::new);
    }

    /**
     * 展示健康百科信息
     * @return
     */
    @Override
    public List<HealthyEssayVo> selectHealthyEssays() {
        List<HealthyEssay> healthyEssays= healthyEssayMapper.selectHealthyEssays();
        return BeanConvertUtils.convertListTo(healthyEssays,HealthyEssayVo::new);
    }

    /**
     * 展示健康百科信息详情
     * @param healthyEssayId
     * @return
     */
    @Override
    public HealthyEssayVo selectHealthyEssay(Long healthyEssayId) {
        HealthyEssay healthyEssay = healthyEssayMapper.selectHealthyEssay(healthyEssayId);
        return BeanConvertUtils.convertTo(healthyEssay,HealthyEssayVo::new);
    }
}
